package com.yhy.dubbo.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yhy.domain.User;
import com.yhy.dubbo.api.UserApi;
import com.yhy.mapper.UserMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class UserApiImpl implements UserApi {

    @Autowired
    private UserMapper userMapper;

    @Override
    public Long save(User user) {
        userMapper.insert(user);
        return user.getId();
    }

    @Override
    public User findByMobile(String phone) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("mobile",phone);
        return userMapper.selectOne(queryWrapper);
    }
}
